** 3D scan SAYCARE project
* Database 3D scan
label define gender 0 "Feminine" 1 "Masculine"
label values gender gender
label define age_group 1 "Children" 2 "11-14 years" 3 "15-18 years", replace
label values age_group age_group 

* Label variables
label variable age_years "Age in years"
label variable age_group "Age Group"
label variable area1_m2 "3D-Area-1"
label variable vol1_lt "3D-Volumen-1"
label variable area2_m2 "3D-Area-2"
label variable vol2_lt "3D-Volumen-2"
label variable ant5a "Weight_1"label variable ant5b "Weight_2"label variable ant5c "Weight_3"label variable ant6a "Height_1"label variable ant6b "Height_2"label variable ant6c "Height_3"label variable ant12a "Waist_1"label variable ant12b "Waist_2"label variable ant12c "Waist_3"
********** Sample Size
sampsi 2139 2225, sd1(224) onesample

*** ========= Relialibility assessment ========= 

********** Figure 2

concord area1_m2 area2_m2, ccc(ms(O i) mcolor(red) lopts(lp(dash)))
concord vol1_lt vol2_lt, ccc(ms(O i) mcolor(red) lopts(lp(dash)))

********** Figure 3

*** Curve ROC analysis to estimate the sensibility and specificity of this method 
*** �gold-standard� waist-to-height ratio (WHtR) cut-off point to abdominal obesity 0.5
gen obesity=0
replace obesity = 1 if waist_height_ratio1 > 0.5
label define obesity 0 "No" 1 "Yes"
label values obesity obesity

******* ROC Curve --- Area to Volume Rate (AV-R)
gen vol1_m3=vol1_lt/1000
gen vol1_area1= vol1_l/area1_m2

*** cut-off point 48
gen ob48_VA=0
replace ob48_VA = 1 if vol1_area1 > 48
tab obesity ob48_VA, chi2
roctab obesity ob48_VA, detail
roctab obesity ob48_VA, graph

*** cut-off point 44
gen ob44_VA=0
replace ob44_VA = 1 if vol1_area1 > 44
tab obesity ob44_VA, chi2
roctab obesity ob44_VA, detail
roctab obesity ob44_VA, graph

********** Table 1
* Waist by age_group and gender
by gender, sort : tabstat waist_1, statistics( count mean sd cv ) by(age_group)
* Height by age_group and gender
by gender, sort : tabstat height_1, statistics( count mean sd cv ) by(age_group)
* Waist to Height Ratio by age_group and gender
gen waist_height_ratio1 = waist_1/height_1
by gender, sort : tabstat waist_height_ratio1, statistics( count mean sd cv ) by(age_group)

********** Table 2
by gender, sort : tabstat area1_m2 area2_m2 vol1_lt vol2_lt, statistics( count mean sd ) by(age_group)

concord area1_m2 area2_m2 if age_group==1, by(gender) stats(rho obs p)
concord area1_m2 area2_m2 if age_group==2, by(gender) stats(rho obs p)
concord area1_m2 area2_m2 if age_group==3, by(gender) stats(rho obs p)

concord vol1_lt vol2_lt if age_group==1, by(gender) stats(rho obs p)
concord vol1_lt vol2_lt if age_group==2, by(gender) stats(rho obs p)
concord vol1_lt vol2_lt if age_group==3, by(gender) stats(rho obs p)

********** Table 3
by obesity, sort : tabstat area1_m2 area2_m2 vol1_lt vol2_lt, statistics( count mean sd ) by(age_group)
concord area1_m2 area2_m2 if age_group==1, by(obesity) stats(rho obs p)
concord area1_m2 area2_m2 if age_group==2, by(obesity) stats(rho obs p)
concord area1_m2 area2_m2 if age_group==3, by(obesity) stats(rho obs p)

concord vol1_lt vol2_lt if age_group==1, by(obesity) stats(rho obs p)
concord vol1_lt vol2_lt if age_group==2, by(obesity) stats(rho obs p)
concord vol1_lt vol2_lt if age_group==3, by(obesity) stats(rho obs p)
